{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "5060dc29",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入模块\n",
    "from requests_html import HTMLSession\n",
    "import json\n",
    "import pandas as pd\n",
    "import copy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "13d98172",
   "metadata": {},
   "outputs": [
    {
     "ename": "JSONDecodeError",
     "evalue": "[Errno Expecting value] \r\n\r\n\r\n: 6",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mJSONDecodeError\u001b[0m                           Traceback (most recent call last)",
      "File \u001b[1;32mD:\\anaconda3\\lib\\site-packages\\requests\\models.py:910\u001b[0m, in \u001b[0;36mResponse.json\u001b[1;34m(self, **kwargs)\u001b[0m\n\u001b[0;32m    909\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 910\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m complexjson\u001b[38;5;241m.\u001b[39mloads(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtext, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m    911\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m JSONDecodeError \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m    912\u001b[0m     \u001b[38;5;66;03m# Catch JSON-related errors and raise as requests.JSONDecodeError\u001b[39;00m\n\u001b[0;32m    913\u001b[0m     \u001b[38;5;66;03m# This aliases json.JSONDecodeError and simplejson.JSONDecodeError\u001b[39;00m\n",
      "File \u001b[1;32mD:\\anaconda3\\lib\\site-packages\\simplejson\\__init__.py:514\u001b[0m, in \u001b[0;36mloads\u001b[1;34m(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, allow_nan, **kw)\u001b[0m\n\u001b[0;32m    510\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (\u001b[38;5;28mcls\u001b[39m \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m encoding \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m object_hook \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m\n\u001b[0;32m    511\u001b[0m         parse_int \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m parse_float \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m\n\u001b[0;32m    512\u001b[0m         parse_constant \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m object_pairs_hook \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m    513\u001b[0m         \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m use_decimal \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m allow_nan \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m kw):\n\u001b[1;32m--> 514\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_default_decoder\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdecode\u001b[49m\u001b[43m(\u001b[49m\u001b[43ms\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    515\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mcls\u001b[39m \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
      "File \u001b[1;32mD:\\anaconda3\\lib\\site-packages\\simplejson\\decoder.py:386\u001b[0m, in \u001b[0;36mJSONDecoder.decode\u001b[1;34m(self, s, _w, _PY3)\u001b[0m\n\u001b[0;32m    385\u001b[0m     s \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mstr\u001b[39m(s, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencoding)\n\u001b[1;32m--> 386\u001b[0m obj, end \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraw_decode\u001b[49m\u001b[43m(\u001b[49m\u001b[43ms\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    387\u001b[0m end \u001b[38;5;241m=\u001b[39m _w(s, end)\u001b[38;5;241m.\u001b[39mend()\n",
      "File \u001b[1;32mD:\\anaconda3\\lib\\site-packages\\simplejson\\decoder.py:416\u001b[0m, in \u001b[0;36mJSONDecoder.raw_decode\u001b[1;34m(self, s, idx, _w, _PY3)\u001b[0m\n\u001b[0;32m    415\u001b[0m         idx \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m3\u001b[39m\n\u001b[1;32m--> 416\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mscan_once\u001b[49m\u001b[43m(\u001b[49m\u001b[43ms\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43midx\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m_w\u001b[49m\u001b[43m(\u001b[49m\u001b[43ms\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43midx\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mend\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[1;31mJSONDecodeError\u001b[0m: Expecting value: line 4 column 1 (char 6)",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001b[1;31mJSONDecodeError\u001b[0m                           Traceback (most recent call last)",
      "Input \u001b[1;32mIn [21]\u001b[0m, in \u001b[0;36m<cell line: 31>\u001b[1;34m()\u001b[0m\n\u001b[0;32m     28\u001b[0m r \u001b[38;5;241m=\u001b[39m session\u001b[38;5;241m.\u001b[39mpost(url, data\u001b[38;5;241m=\u001b[39mjson\u001b[38;5;241m.\u001b[39mdumps(payload), headers\u001b[38;5;241m=\u001b[39mheaders)\n\u001b[0;32m     30\u001b[0m \u001b[38;5;66;03m# 提取json\u001b[39;00m\n\u001b[1;32m---> 31\u001b[0m response_data \u001b[38;5;241m=\u001b[39m \u001b[43mr\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mjson\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m     32\u001b[0m \u001b[38;5;28mprint\u001b[39m(response_data)\n",
      "File \u001b[1;32mD:\\anaconda3\\lib\\site-packages\\requests\\models.py:917\u001b[0m, in \u001b[0;36mResponse.json\u001b[1;34m(self, **kwargs)\u001b[0m\n\u001b[0;32m    915\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m RequestsJSONDecodeError(e\u001b[38;5;241m.\u001b[39mmessage)\n\u001b[0;32m    916\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 917\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m RequestsJSONDecodeError(e\u001b[38;5;241m.\u001b[39mmsg, e\u001b[38;5;241m.\u001b[39mdoc, e\u001b[38;5;241m.\u001b[39mpos)\n",
      "\u001b[1;31mJSONDecodeError\u001b[0m: [Errno Expecting value] \r\n\r\n\r\n: 6"
     ]
    }
   ],
   "source": [
    "url = 'https://fe-api.zhaopin.com/c/i/search/positions?MmEwMD=5EvALUONrCqBaksHHaABimAFnyFckiXxy0LBw8LfyT_b6oe3TU6ZaWGIy6cpPtWk.2QWmKyR5LbbEuNAF_inJbiYI54uIDC2YyQ2Jrd722mBb_yhKL5X5IUrLAFZvy96Th2va8MocTLtufPn9fsXhtt.KB0tTVGyeNj1iXVHLbSK19KHK9._x3o3_3fcz7V0NInXV8eD0cZDwDX52_JUMye9xFIJuajVKeh6FWcvXZzMi_aCczKN_jUxgwGYzAx.7P4E4082ecQjLe5MuCPuwd9k.Lf3ekjclw.QimdfUuKg.0MGcAr8tiRBR7rChT9SrgHJq4MxIcD8gE8eUbklsZ2w48KLWl08mGaP9RKwn0Xs03jK1KPQhZnyWqAY4NyW3&c1K5tw0w6_=4o_mz_GAbUYamIZae4sixTS.sF3Yj9B1JbFktgbMI3bi8FyUV1phposuMTfPVqyuAMfp2Oyj6YO.jsv78mt5wDbrSFU8lQTMHmCRAt5.JozjMYLNDbibGFqiHbUsYLHgbf.rodobk6nHMUX7F6lfypbhuUL.5U7sj.bvrYoI4Z2dH.SDOO.DydKH_GKm79WBE8.uFXlgoF7oX34DJmYQqxDDfc4j2LIsUnijANjNH3Svzgx5urCdnQBiPFlY1VZCRva1NftYkpkALiXElcOxJvb1N9TKyfYGcMYHkQ3XnLqS4bf0V_TNyugdY6MycQpzGXOD3PTT_t6x_EQ73bjMR.KkaJo9.836ytXcb3Coi8fwJf4gKsETBs228PIAkT_u1Pj7zrliYqIhPZjTUjjgzVdXi6dzUsmNlTG1nQYwrmH8I6UeAH_cay60mWu2KU3p7ZmSO1HV4PIAE.FApq9qmBq'\n",
    "\n",
    "payload = {\n",
    "    \"S_SOU_FULL_INDEX\": \"用户增长\",\n",
    "    \"S_SOU_WORK_CITY\": \"763\",\n",
    "    \"anonymous\": 0,\n",
    "    \"cvNumber\": \"JH208833940R90500000000\",\n",
    "    \"eventScenario\": \"pcSearchedSouSearch\",\n",
    "    \"pageIndex\":1,\n",
    "    \"pageSize\": 30\n",
    "}\n",
    "\n",
    "# 创建会话\n",
    "session = HTMLSession()\n",
    "\n",
    "# 设置头部\n",
    "headers = {\n",
    "    \"Accept\": \"application/json, text/plain, */*\",\n",
    "    \"Accept-Encoding\": \"gzip, deflate, br\",\n",
    "    \"Accept-Language\": \"zh-CN,zh;q=0.9\",\n",
    "    \"Content-Type\": \"application/json;charset=UTF-8;\",\n",
    "    \"Cookie\": \"x-zp-client-id=72c5454d-7772-445c-9737-e138f12c18de; LastCity=%E5%B9%BF%E5%B7%9E; LastCity%5Fid=763; locationInfo_search={%22code%22:%22763%22%2C%22name%22:%22%E5%B9%BF%E5%B7%9E%22%2C%22message%22:%22%E5%8C%B9%E9%85%8D%E5%88%B0%E5%B8%82%E7%BA%A7%E7%BC%96%E7%A0%81%22}; selectCity_search=763; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%221120883394%22%2C%22first_id%22%3A%2218842480e3d94c-0117cf1e214a608-26031a51-921600-18842480e3e1184%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E8%87%AA%E7%84%B6%E6%90%9C%E7%B4%A2%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fcn.bing.com%2F%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTg4NDI0ODBlM2Q5NGMtMDExN2NmMWUyMTRhNjA4LTI2MDMxYTUxLTkyMTYwMC0xODg0MjQ4MGUzZTExODQiLCIkaWRlbnRpdHlfbG9naW5faWQiOiIxMTIwODgzMzk0In0%3D%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%24identity_login_id%22%2C%22value%22%3A%221120883394%22%7D%2C%22%24device_id%22%3A%2218842480e3d94c-0117cf1e214a608-26031a51-921600-18842480e3e1184%22%7D; at=fba71b947c6b40dea91909f837cbe6ea; rt=58f03af5a8d647bd8afb4611b4b6942b; IMDate=20230529; sts_deviceid=1886695c869af7-016ca45de5adbd-26031a51-921600-1886695c86aa92; sts_sg=1; sts_chnlsid=Unknown; zp_src_url=https%3A%2F%2Fwww.zhaopin.com%2F; ZP_OLD_FLAG=false; Hm_lvt_38ba284938d5eddca645bb5e02a02006=1684739332,1685348273; ssxmod_itna=YqjxgD2DyDn0wxQq0dK8+YDCDceO8rD0lcQrGx054yeiODUxn4iaDT=oq3t=Yt0rmKPE4bx2D=+bE0yfmdomocbzHDCPGnGPODKXD44GTDt4DTD34DYDixib0DivdDjxGPc0vTv=DEDmbzDYHFDQvsx4DFUAKO44i7DD5DApPDwaA8DiWF4S+p2PhIYGG8D7HhDlP5E3+8rf3L+GvI+bSsEiKDXEdDvr5w0OoDUnIzcZHNQmRDQQxNo=x5Lex487DqmiGuPex5ilhY6Gi43Y+BzMcPFZQDic+a4D; ssxmod_itna2=YqjxgD2DyDn0wxQq0dK8+YDCDceO8rD0lcQrDnK3+xqDsY8eDLQeP=u/b0QqnRDPg+DwnN4qRr0p4rVB0ov4H8QlThcxYix7QrUDjKD2eoD=; ZL_REPORT_GLOBAL={%22//i%22:{%22actionid%22:%22aea6961c-55c1-4458-a772-931b1a48d9e1-i%22%2C%22funczone%22:%22back_best_for_you%22}%2C%22jobs%22:{%22funczoneShare%22:%22dtl_best_for_you%22%2C%22recommandActionidShare%22:%220eed8688-1a92-4d1c-8067-794c5b8b93ef-job%22}}; acw_tc=2760828316853500572783704e28a107a3fba5b4a10f0288d00935048ba887; Hm_lpvt_38ba284938d5eddca645bb5e02a02006=1685351634\",\n",
    "    \"Sec-Ch-Ua\": \"'Google Chrome';v='113', 'Chromium';v='113', 'Not-A.Brand';v='24'\",\n",
    "    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36\",\n",
    "}\n",
    "\n",
    "# post请求\n",
    "r = session.post(url, data=json.dumps(payload), headers=headers)\n",
    "\n",
    "# 提取json\n",
    "response_data = r.json()\n",
    "print(response_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "86aca7bf",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
